import { request } from '@/request'
import { AddDishData, DishItem, DishParams, DishResult, TreeResult } from '@/types/dish'

export function getDishListApi(params: DishParams) {
  return request<DishResult>(
    '/admin/dish/page', "get", params
  )
}

export function updateStatusApi(id: number, status: number,) {
  return request(
    `/admin/dish/status/${status}`, "post", { id }, true
  )
}

export function addDishApi(data: AddDishData) {
  return request(
    '/admin/dish', "post", data
  )
}

export function getDishDetailApi(id: number) {
  return request<DishItem>(
    `/admin/dish/${id}`, "get"
  )
}

export function updateDishApi(data: AddDishData) {
  return request(
    '/admin/dish', "put", data
  )
}

export function deleteDishApi(ids: string) {
  return request(
    '/admin/dish', "delete", { ids }
  )
}

export function getDishListByIdApi(categoryId:number) {
  return request<DishItem[]>(
    '/admin/dish/list', "get", { categoryId }
  )
}

export function getTreeApi() {
  return request<TreeResult[]>(
    '/admin/dish/tree', "get"
  )
}